package com.anti.jdbc.support.page;

import java.io.Serializable;
import java.util.List;

/**
 * @Description TODO
 * @Author anTi
 * @Date 2020-10-6
 */
public class PageResult implements Serializable {
    /**
     * 第几页
     */
    private Integer pageIndex = 0;

    /**
     * 每页条数
     */
    private Integer pageSize = 20;

    /**
     * 总页数
     */
    private Integer totalPage = 0;

    /**
     * 总记录数
     */
    private Integer total = 0;

    private List<?> data;

    public PageResult() {
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getTotalPage() {
        return this.total % this.pageSize == 0 ? this.total / this.pageSize : this.total / this.pageSize + 1;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<?> getData() {
        return this.data;
    }

    public void setData(List<?> data) {
        this.data = data;
    }

    public Integer getPageCount() {
        if (this.pageSize < 1) {
            return 1;
        } else {
            return this.totalPage;
        }
    }

    public int getSize() {
        return this.data != null ? this.data.size() : 0;
    }
}
